package com.hurteng.stormplane.comm;

import android.util.Log;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.PipedOutputStream;

public class CommRecvThread extends Thread {
    private DataInputStream socketInputStream;
    private PipedOutputStream threadOutputStream;

    public CommRecvThread(DataInputStream socketInputStream) {
        this.socketInputStream = socketInputStream;
        threadOutputStream = new PipedOutputStream();
        this.setDaemon(true);
    }

    public PipedOutputStream getThreadOutputStream() {
        return threadOutputStream;
    }

    @Override
    public void run() {
        super.run();

        byte[] buffer = new byte[8192];

        try {
            int length = socketInputStream.read(buffer);
            threadOutputStream.write(buffer, 0, length);
        } catch (IOException e) {
            Log.d("qinjinyu", e.getMessage());
        }
    }
}
